package com.jason.www.dao.impl;

import com.jason.www.dao.UserDao;
import com.jason.www.pojo.User;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;

import java.io.Serializable;
import java.util.List;

/**
 * Created by Cai on 2018/6/16.
 */
public class UserDaoImpl extends HibernateDaoSupport implements UserDao{


    @Override
    public List<User> findAllUser() {
        return getHibernateTemplate().findByExample(new User());
    }

    @Override
    public User findUserById(Long id) {
        return getHibernateTemplate().get(User.class,id);
    }

    @Override
    public Boolean insertUser(User user) {
        Serializable result = getHibernateTemplate().save(user);
        return result == null ? false : true;
    }

    @Override
    public void updaeteUser(User user) {
        getHibernateTemplate().update(user);
    }

    @Override
    public void deleteUser(User user) {
        getHibernateTemplate().delete(user);
    }
}
